package test;

import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Map;

import org.hibernate.dialect.Oracle9iDialect;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.hbm2x.Hbm2DDLExporter;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.lb.trac.dao.DAOService;

public class TEST {
	public static void main(String[] args) throws IOException {
		// String sql = "select * from (SELECT   " + "t.* " + "FROM   "
		// + "tickets t " + "WHERE       " + "t.STATO_TICKET IN (1) AND "
		// + "t.ID_OWNER NOT IN ("
		// + "3"
		// + ")"
		// + "union "
		// + "SELECT   "
		// + "T.*  "
		// + "FROM   "
		// + "tickets t "
		// + "WHERE       "
		// + "(t.STATO_TICKET = 1 OR t.stato_ticket = 2) AND "
		// + "t.id_owner = "
		// + "3"
		// + " AND "
		// + "id_progetto IN ("
		// + "SELECT   "
		// + "p.id_progetto "
		// + "FROM "
		// + "progetti p, "
		// + "utente_progetto UP "
		// + "WHERE "
		// + "p.id_progetto = UP.id_progetto AND "
		// + "UP.id_utente = t.id_OWNER" + ") ) order by stato_ticket";
		// Oracle9iDialect dialect = new Oracle9iDialect();
		// System.out.println(dialect.getLimitString(sql, 0, 5));
		// System.setOut(new PrintStream(new
		// FileOutputStream("/Users/edoardo/tracsetup.db")));
		// SchemaExport.main(new
		// String[]{"--config=/com/setup/trac/etc/hibernate_creator.cfg.xml","--create","--delimiter=;","--format"});
		JSONArray ja = new JSONArray();
		Map m1 = new HashMap();
		for (int i = 0; i < 5; i++) {
			Map m2 = new HashMap();
			m2.put("a" + i, "1");
			m2.put("b" + i, "2");
			m2.put("c" + i, "3");
			ja.put(m2);
		}
		m1.put("items", ja);

		JSONObject jo = new JSONObject(m1);
		System.out.println(jo.toString());
		// String x = "000";
		// String y = "222";
		// x = x.substring(0,x.length()-y.length())+y;
		// System.out.println(x);
	}
}
